package com.etc.myblog.biz;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.etc.myblog.dao.RankDao;
import com.etc.myblog.entity.Rank;
import com.etc.myblog.util.SessionFactoryUtil;

public class RankBiz {

	public List<Rank> find(){
		List<Rank> list = new ArrayList<Rank>();
		SqlSession session = SessionFactoryUtil.getSession();
		try{
			RankDao dao= session.getMapper(RankDao.class);
			list = dao.find();
			
		}catch(Exception e){
			System.out.println(e.getMessage());
		}finally{
			session.close();
		}
		return list;
	}
	public Rank findRankByrankId(int rankId){
		Rank rank = new Rank();
		SqlSession session = SessionFactoryUtil.getSession();
		try{
			RankDao dao = session.getMapper(RankDao.class);
			rank = dao.findRankByrankId(rankId);
		}catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			session.close();
		}
		return rank;
	}
}
